﻿using System;
using System.Data;
using System.Configuration;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Meqs.Entity;
using Meqs.Entity.Parameters;
using Meqs.Logic;
using Meqs.Logic.Interface;
using Meqs.Utilities;
using System.Collections.Generic;


/// <summary>
/// ScoreInputBasePage 的摘要说明
/// </summary>
public class ScoreInputBasePage : ContainerBasePage
{
    /// <summary>
    /// 学年
    /// </summary>
    protected static int SchoolYear
    {
        get
        {
            int year;
            if (int.TryParse(HttpContext.Current.Request["SchoolYear"], out year)) return year;
            return -1;
        }
    }

    /// <summary>
    /// 学期
    /// </summary>
    protected static int Term
    {
        get
        {
            int term;
            if (int.TryParse(HttpContext.Current.Request["Term"], out term)) return term;
            return -1;
        }
    }
    /// <summary>
    /// 学年
    /// </summary>
    protected static int Year
    {
        get
        {
            int year;
            if (int.TryParse(HttpContext.Current.Request["Year"], out year)) return year;
            return -1;
        }
    }

    /// <summary>
    /// 学期
    /// </summary>
    protected static int Month
    {
        get
        {
            int month;
            if (int.TryParse(HttpContext.Current.Request["Month"], out month)) return month;
            return -1;
        }
    }

    /// <summary>
    /// 班级ID
    /// </summary>
    protected static int ClsID
    {
        get
        {
            int clsID;
            if (int.TryParse(HttpContext.Current.Request["ClsID"], out clsID)) return clsID;
            return -1;
        }
    }

    /// <summary>
    /// 只读/可写
    /// </summary>
    protected bool IsModify
    {
        get
        {
            if (string.IsNullOrEmpty(HttpContext.Current.Request["Type"])) return false;
            return HttpContext.Current.Request["Type"].ToLower() == "edit";
        }
    }


    /// <summary>
    /// 学科ID
    /// </summary>
    protected static int CauseID
    {
        get
        {
            int causeID;
            if (int.TryParse(HttpContext.Current.Request["CauseID"], out causeID)) return causeID;
            return -1;
        }
    }

    protected static GlobalCauseInfo Cause
    {
        get
        {
            if (CauseID == -1) return null;
            return Container<IGlobalCauseInfoLogic>.Instance.FindById(CauseID);
        }
    }

    /// <summary>
    /// 评价样表ID(HistoryId)
    /// </summary>
    protected static int HistoryId
    {
        get
        {
            int historyId;
            if (int.TryParse(HttpContext.Current.Request["HistoryId"], out historyId)) 
                return historyId;
            return -1;
        }
    }

    /// <summary>
    /// 评价方式 1:日报 2:周报 3:月报
    /// </summary>
    protected static int Attribute
    {
        get
        {
            int evalAttribute;
            if (int.TryParse(HttpContext.Current.Request["Attribute"], out evalAttribute)) return evalAttribute;
            return -1;
        }
    }

    protected IList<ParamVal> _paramVals = new List<ParamVal>();
    protected IList<ParamVal> ParamVals
    {
        get
        {
            return _paramVals;
        }
        set
        {
            _paramVals = value;
        }
    }

    /// <summary>
    /// 计次
    /// </summary>
    protected static string ScoreInputNumericHtmlStr
    {
        get
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("<table style=\"width: 60px; height: 42px; border: 0px;\">");
            sb.AppendLine("    <tr>");
            sb.AppendLine("        <td>");
            sb.AppendLine("        	<input id=\"{0}\" oldvalue=\"{1}\" value=\"{1}\" maxlength=\"4\" Score=\"{2}\" MoralityType=\"2\" Math=\"{3}\" type=\"text\" class=\"txtStyle\" onfocusout=\"optionSettingScore(this, 2)\" style=\"height: 42px; width: 30px; text-align: center;\" />");
            sb.AppendLine("        </td>");
            sb.AppendLine("        <td style=\"display: none;\">");
            sb.AppendLine("        	<img src=\"../../Common/images/add_icon.gif\" onclick=\"add(this)\" style=\"cursor: hand;\" alt=\"\" />");
            sb.AppendLine("        	<img src=\"../../Common/images/minus_icon.gif\" onclick=\"minus(this)\" style=\"cursor: hand;\" alt=\"\" />");
            sb.AppendLine("        </td>");
            sb.AppendLine("    </tr>");
            sb.AppendLine("</table>");
            return sb.ToString();
        }
    }

    /// <summary>
    /// 计分
    /// </summary>
    protected static string ScoreInputScoreHtmlStr
    {
        get
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("<table style=\"width: 60px; height: 32px; border: 0px solid white;\">");
            sb.AppendLine("    <tr>");
            sb.AppendLine("        <td>");
            sb.AppendLine("             <input id=\"{0}\" oldvalue=\"{1}\" value=\"{1}\" Score=\"{2}\" maxlength=\"4\" MoralityType=\"1\" type=\"text\" class=\"txtStyle\" onfocusout=\"optionSettingScore(this, 1)\" style=\"height: 32px; width: 54px; text-align: center;");
            sb.AppendLine("                 float: left;\" />");
            sb.AppendLine("        </td>");
            sb.AppendLine("    </tr>");
            sb.AppendLine("</table>");
            return sb.ToString();
        }
    }

    protected static string TeacherName
    {
        get
        {
            return HttpContext.Current.Server.UrlDecode( HttpContext.Current.Request["TeacherName"]);
        }
    }

    protected static int EvalTeacherID
    {
        get
        {
            int teacherId;
            if (int.TryParse(HttpContext.Current.Request["TeacherId"], out teacherId)) return teacherId;
            return -1;
        }
    }

    protected static string TeacherCode
    {
        get
        {
            return HttpContext.Current.Request["TeacherCode"];
        }
    }

}
